<script setup lang="ts">
defineProps<{
  loading: boolean
  shadowColor?: string
}>()
</script>

<template>
  <div class="loading-container">
    <div
      v-if="loading" class="loading-overlay" :style="{
        backgroundColor: shadowColor || 'rgba(255, 255, 255, 0.8)',
        boxShadow: `0 0 10px 10px ${shadowColor || 'rgba(255, 255, 255, 0.8)'}`,
      }"
    >
      <div class="loading-content">
        <slot name="loading">
          <div class="loading-spinner" />
        </slot>
      </div>
    </div>
    <slot />
  </div>
</template>

<style scoped>
.loading-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
</style>
